package com.jinbo.footmessage;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.view.MenuItem;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.jinbo.footmessage.collection.MyCollectionActivity;
import com.jinbo.footmessage.httpbean.UserInformationBean;
import com.jinbo.footmessage.httpbean.WorkerInformationBean;
import com.jinbo.footmessage.httpbean.WorkersBean;
import com.jinbo.footmessage.httpretrofit.BusinessController;
import com.jinbo.footmessage.httpretrofit.HttpProtocolFactory;
import com.jinbo.footmessage.httpretrofit.Listener;
import com.jinbo.footmessage.login.LoginActivity;
import com.jinbo.footmessage.login.PersonInfoActivity;
import com.jinbo.footmessage.lookServers.LookServersActivity;
import com.jinbo.footmessage.order.OrderActivity;
import com.jinbo.footmessage.serverInf.ServerInfActivity;
import com.jinbo.footmessage.setting.SettingActivity;
import com.jinbo.footmessage.utils.LocalPreferencesHelper;
import com.jinbo.footmessage.view.TitleBarView;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;


public class NavigationActivity extends BaseActivity//AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener, OnClickListener {
   /* private static final int REQUEST_IMAGE = 100;
    private static final int REQUEST_CROP = 101;
    private static final int REQUEST_TAKE_PICTURE = 102;

    //public static final String IMAGE_FILE_LOCATION = new File(MyApplication.app.getTmpDir(),"temp.jpg").getAbsolutePath();//"file:///sdcard/temp.jpg";//temp file
    //public static final File temp= new File(Environment.getExternalStorageDirectory(),"temp.jpg");
    public static final File temp= new File(MyApplication.app.getTmpDir(),"temp.jpg");
    public static final File des= new File(MyApplication.app.getTmpDir(),"head.jpg");
    public static final Uri imageUri=Uri.fromFile(temp);
    public static final Uri desUri=Uri.fromFile(des);*/
    // Uri.parse(IMAGE_FILE_LOCATION);//The Uri to store the big bitmap
    //TextView word;

    private static final int REQUEST_UPDATE = 100;//更改头像后主页面修改

    // private static final int REQUEST_SETTING = 101;//设置中退出状态改变，主页面相应改变

    TextView mName;
    CircleImageView mCircleImage;
    CircleImageView img_head_view;

    private ListView listView;
    private View headerView;

    private Button mLeftBt, mRightBt;
    private ImageButton mLookBt, mCollectBt;
    private View mLoadView;
    List<WorkerInformationBean> workers;


    List<MyRandOrderBean> order_workers = new ArrayList<MyRandOrderBean>();
    List<MyRandStarBean> star_workers = new ArrayList<MyRandStarBean>();



    public static void launch(Activity activity) {
        Intent intent = new Intent(activity, NavigationActivity.class);
        activity.startActivity(intent);
    }

    DrawerLayout drawer;
    String mId;

    ServerListViewAdapter listViewAdapter;

    ServerOrderListViewAdapter orderListViewAdapter;
    ServerStarListViewAdapter starListViewAdapter;
    //int rand_flag = 0;//0 代表order 1代表star

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_navigation);
        TitleBarView titleBarView = (TitleBarView) findViewById(R.id.titleBar);
        titleBarView.setCenterTitle("沐足");
        titleBarView.setLeftHeadIsVisibler(true);
        titleBarView.setListener(TitleBarView.TitleBarEnum.icv_head, this);
        drawer = (DrawerLayout) findViewById(R.id.drawer_layout);

        ////透明状态栏
        //        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        // //透明导航栏
        //        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
        //word = (TextView) findViewById(R.id.word);
        ///Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        //setSupportActionBar(toolbar);

        img_head_view = (CircleImageView) findViewById(R.id.icv_head);
        NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
        navigationView.setNavigationItemSelectedListener(this);
        View header = navigationView.getHeaderView(0);
        mName = (TextView) header.findViewById(R.id.textView);
        mCircleImage = (CircleImageView) header.findViewById(R.id.imageView);



        /* FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
            fab.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
         });*/

        //   DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        //  ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
        //         this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        // drawer.setDrawerListener(toggle);
        //  toggle.syncState();


        mCircleImage.setOnClickListener(this);
        mName.setOnClickListener(this);

        headerView = LayoutInflater.from(this).inflate(R.layout.main_listview_header, null);

        mLoadView = headerView.findViewById(R.id.loading);

        mLeftBt = (Button) headerView.findViewById(R.id.left);
        mRightBt = (Button) headerView.findViewById(R.id.right);
        mRightBt.setEnabled(true);
        mLeftBt.setEnabled(false);
        mLeftBt.setOnClickListener(this);
        mRightBt.setOnClickListener(this);

        mLookBt = (ImageButton) headerView.findViewById(R.id.look_btn);
        mCollectBt = (ImageButton) headerView.findViewById(R.id.collect_btn);
        mLookBt.setOnClickListener(this);
        mCollectBt.setOnClickListener(this);

        listView = (ListView) findViewById(R.id.mainListView);//列表
        listView.addHeaderView(headerView);

        listViewAdapter = new ServerListViewAdapter(this, workers);
        listView.setAdapter(listViewAdapter);

        //orderListViewAdapter = new ServerOrderListViewAdapter(this, order_workers);
       // listView.setAdapter(orderListViewAdapter);


        listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                ServerInfActivity.launch(NavigationActivity.this,(WorkerInformationBean)listView.getAdapter().getItem(position));
             /*   if (rand_flag == 0) {
                    show("order" + position + ((MyRandOrderBean) listView.getAdapter().getItem(position)).getName());
                }
                if (rand_flag == 1) {
                    show("star" + position+((MyRandStarBean)listView.getAdapter().getItem(position)).getName());
                }*/
               // String str=(.getName();
               // show(str);
            }
        });

        mId = MyApplication.local.getString(LocalPreferencesHelper.USER_ID);

        if (!mId.equals("")) {
            final String name = MyApplication.local.getString(mId + LocalPreferencesHelper.USER_NAME);
            final String head = MyApplication.local.getString(mId + LocalPreferencesHelper.USER_HEAD_URL);
            if (!name.equals(""))
                mName.setText(name);
            if (!head.equals("")) {
                String userHead = HttpProtocolFactory.HOST_URL_USER + head;
                // new DialogUtils(NavigationActivity.this, "center", true, 0).setMessage(userHead).setButtons(null, "确定", null).create().show();
                Glide.with(NavigationActivity.this)
                        .load(userHead)
                                // .placeholder(R.mipmap.ic_launcher)
                                // .crossFade()
                        .into(mCircleImage)
                ;

                Glide.with(NavigationActivity.this)
                        .load(userHead)
                                //.placeholder(R.mipmap.ic_launcher)
                                // .crossFade()
                        .into(img_head_view);

                // Glide.clear(mCircleImage);
            }


            String mobile = MyApplication.local.getString(mId + LocalPreferencesHelper.USER_MOBILE);
            final String password = MyApplication.local.getString(mId + LocalPreferencesHelper.USER_PASSWORD);
            // String headPath=MyApplication.local.getString(id+LocalPreferencesHelper.USER_HEAD_PATH);
            BusinessController.getInstance().login(mobile, password, new Listener<UserInformationBean>() {
                @Override
                public void onStart(Object... params) {

                    // showProgressDialog("请稍后...");
                }

                @Override
                public void onComplete(UserInformationBean result, Object... params) {
                    // dismissProgressDialog();
                    // show("登录成功" + result.user_id);
                    //   MyApplication.local.saveOrUpdate(LocalPreferencesHelper.USER_ID, result.user_id);//其他属性都应该为ID+""
                    //   String id = result.user_id;
                    MyApplication.local.saveOrUpdate(mId + LocalPreferencesHelper.USER_SEX, result.sex);
                    MyApplication.local.saveOrUpdate(mId + LocalPreferencesHelper.USER_MOBILE, result.mobile);
                    MyApplication.local.saveOrUpdate(mId + LocalPreferencesHelper.USER_PASSWORD, password);
                    MyApplication.local.saveOrUpdate(mId + LocalPreferencesHelper.USER_NAME, result.name);
                    MyApplication.local.saveOrUpdate(mId + LocalPreferencesHelper.USER_HEAD_URL, result.head);
                    MyApplication.local.saveOrUpdate(mId + LocalPreferencesHelper.USER_MAIl, result.mail);
                    // NavigationActivity.launch(LoginActivity.this);
                    if (!name.equals(result.name))
                        mName.setText(result.name);
                    //String head = result.head;
                    if (!head.equals(head)) {
                        if (!TextUtils.isEmpty(result.head)) {
                            String userHeadUrl = HttpProtocolFactory.HOST_URL_USER + head;
                            // new DialogUtils(NavigationActivity.this, "center", true, 0).setMessage("刷新"+userHeadUrl).setButtons(null, "确定", null).create().show();
                            Glide.with(NavigationActivity.this)
                                    .load(userHeadUrl)
                                            //.placeholder(R.mipmap.ic_launcher)
                                            //.crossFade()

                                    .into(mCircleImage);

                            Glide.with(NavigationActivity.this)
                                    .load(userHeadUrl)
                                            // .placeholder(R.mipmap.ic_launcher)
                                            // .crossFade()
                                            //
                                    .into(img_head_view);
                            // Glide.clear(mCircleImage);
                        }
                    }
                }

                @Override
                public void onFail(final String msg, Object... params) {
                    show("网络异常,请稍后重试");
                    //当密码不一致时，执行下面的判断。。。通过msg判断
              /*  show(msg);
              LoginActivity.launch(ModifyPwdActivity.this);
                finish();
                ActivitiesHelper.getInstance().closeAll();*/
                }
            });
        }

        BusinessController.getInstance().LookWorkers(new Listener<WorkersBean>() {
            @Override
            public void onStart(Object... params) {
                mLoadView.setVisibility(View.VISIBLE);
            }

            @Override
            public void onComplete(WorkersBean result, Object... params) {
                mLoadView.setVisibility(View.GONE);
                workers = result.workers;
                for (int i = 0; i < workers.size(); i++) {
                    MyRandOrderBean orderBean = new MyRandOrderBean();
                    MyRandStarBean starBean = new MyRandStarBean();
                    orderBean.setId(workers.get(i).id);
                    orderBean.setName(workers.get(i).name);
                    orderBean.setOrder_number(workers.get(i).order_number);
                    orderBean.setHead(workers.get(i).head);
                    orderBean.setSpeciality(workers.get(i).speciality);
                    orderBean.setAge(workers.get(i).age);
                    orderBean.setSex(workers.get(i).sex);
                    orderBean.setStar(workers.get(i).star);

                    starBean.setId(workers.get(i).id);
                    starBean.setName(workers.get(i).name);
                    starBean.setOrder_number(workers.get(i).order_number);
                    starBean.setHead(workers.get(i).head);
                    starBean.setSpeciality(workers.get(i).speciality);
                    starBean.setAge(workers.get(i).age);
                    starBean.setSex(workers.get(i).sex);
                    starBean.setStar(workers.get(i).star);

                    order_workers.add(orderBean);
                    star_workers.add(starBean);
                }
                Collections.sort(order_workers);
                Collections.sort(star_workers);

                Collections.sort(workers, new OrderComparator());
                listViewAdapter.setList(workers);
                listViewAdapter.notifyDataSetChanged();

                //orderListViewAdapter.setOrderList(order_workers);
               // orderListViewAdapter.notifyDataSetChanged();
            }

            @Override
            public void onFail(String msg, Object... params) {
                mLoadView.setVisibility(View.GONE);
                //  new DialogUtils(NavigationActivity.this, "center", true, 0).setMessage(msg).setButtons(null, "确定", null).create().show();
                show("网络异常,请稍后重试");
            }
        });


    }

    /* @Override
     public void onStart() {
         super.onStart();
         id=MyApplication.local.getString(LocalPreferencesHelper.USER_ID);
         if(!id.equals("")) {
             String userName=MyApplication.local.getString(id+LocalPreferencesHelper.USER_NAME);
            // String headPath=MyApplication.local.getString(id+LocalPreferencesHelper.USER_HEAD_PATH);
           //  if (!userName.equals("")) {
          //   String s=MyApplication.local.getString(id + LocalPreferencesHelper.USER_HEAD_URL);
            // new DialogUtils(this, "center", true, 0).setMessage(s).setButtons(null, "确定", null).create().show();
             String userHead= HttpProtocolFactory.HOST_URL_USER+MyApplication.local.getString(id+LocalPreferencesHelper.USER_HEAD_URL);
             mName.setText(userName);

             Glide.with(this)
              .load(userHead)
                .into(mCircleImage);

             Glide.with(this)
                     .load(userHead)
                     .into(img_head_view);

             //   }
            *//* if (!headPath.equals("")) {
                File file=new File(headPath);
                Uri imageUri;
               *//**//* if(file.exists())*//**//*
                imageUri = Uri.fromFile(file);
                mCircleImage.setImageURI(imageUri);
                img_head_view.setImageURI(imageUri);
            }*//*
        }
        else
        {
            mName.setText("登录");
            mCircleImage.setImageResource(R.drawable.head_small);
            img_head_view.setImageResource(R.drawable.head_small);
        }


    }*/
    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.icv_head:
                //-----点击头像
                drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
                drawer.openDrawer(GravityCompat.START);
                break;
            case R.id.imageView:
                // PersonInfoActivity.launch(this);
 /*             DialogUtils dialogUntils = new DialogUtils(NavigationActivity.this,
                        "center", true,1);
                dialogUntils.setButtons(null, "取消",
                    new DialogUtils.OnDialogButtonClickListener() {
                        @Override
                        public void onDialogButtonClick(Context context, DialogUtils builder, Dialog dialog, int dialogId, int which) {
                                       if (which == DialogUtils.OnDialogButtonClickListener.BUTTON_RIGHT) {
                                            // ActivitiesHelper.getInstance().closeAll();
                                           // LoginActivity.launch(FindPasswordActivity.this);
                                        }
                        }
                    });
                dialogUntils.setItems(R.array.sign, new DialogUtils.OnDialogItemClickListener() {

                    @Override
                    public void OnDialogItemClick(Context context,
                                                  DialogUtils builder, Dialog dialog, int position) {
                        if (position == 0) {
                            //CropWrapper.camera(BaseApplication.app.getCropTmpDir(), PersonInfoActivity.this);
                            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);//action is capture
                            intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
                            startActivityForResult(intent, REQUEST_TAKE_PICTURE);
                        } else {
                           // PhotoAllActivity.launch(PersonInfoActivity.this);
                            Intent intent=new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                            //  Intent intent=new Intent(Intent.ACTION_GET_CONTENT);//ACTION_OPEN_DOCUMENT
                            //  intent.addCategory(Intent.CATEGORY_OPENABLE);
                            intent.setType("image*//*");
                            //startActivity(intent);
                            startActivityForResult(intent,REQUEST_IMAGE);
                        }

                    }

                });
                Dialog dialog=dialogUntils.create();//.show();



     *//*          Dialog dialog=new DialogUtils(NavigationActivity.this, "center",true,1)
                        .setMessage("从相册选择")
                        .setButtons(null, "取消",
                                new DialogUtils.OnDialogButtonClickListener() {
                                    @Override
                                    public void onDialogButtonClick(Context context, DialogUtils builder, Dialog dialog, int dialogId, int which) {
                                    *//**//**//**//*    if (which == DialogUtils.OnDialogButtonClickListener.BUTTON_RIGHT) {
                                            // ActivitiesHelper.getInstance().closeAll();
                                            LoginActivity.launch(FindPasswordActivity.this);
                                        }*//**//**//**//*
                                    }
                                }).create();*//**//*

      *//**//*         Window dialogWindow = dialog.getWindow();

                WindowManager.LayoutParams lp = dialogWindow.getAttributes();

                dialogWindow.setGravity( Gravity.BOTTOM);*//*

                WindowManager windowManager = getWindowManager();
                Display display = windowManager.getDefaultDisplay();
                WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
                lp.width = (int)(display.getWidth()); //设置宽度
                Window dialogWindow = dialog.getWindow();
                dialogWindow.setAttributes(lp);
                dialogWindow.setGravity(Gravity.BOTTOM);
                dialog.show();
       *//*   *//* */
                //break;
            case R.id.textView:
                //-----点击抽屉里面的图片
                if (mId.equals(""))
                    LoginActivity.launch(NavigationActivity.this);
                else
                    PersonInfoActivity.launch(this, REQUEST_UPDATE);
                break;
            case R.id.left:
               // rand_flag = 0;
                mLeftBt.setEnabled(false);
                mRightBt.setEnabled(true);


                Collections.sort(workers, new OrderComparator());
                listViewAdapter.setList(workers);
                listViewAdapter.notifyDataSetChanged();

                //listView.setAdapter(orderListViewAdapter);




                //orderListViewAdapter.setOrderList(order_workers);
                //orderListViewAdapter.notifyDataSetChanged();

                break;
            case R.id.right:
               // rand_flag = 1;
                mRightBt.setEnabled(false);
                mLeftBt.setEnabled(true);
                //starListViewAdapter = new ServerStarListViewAdapter(this, star_workers);

                Collections.sort(workers, new StarComparator());
                listViewAdapter.setList(workers);
                listViewAdapter.notifyDataSetChanged();

                //listView.setAdapter(starListViewAdapter);

                //starListViewAdapter.setStarList(star_workers);
                //starListViewAdapter.notifyDataSetChanged();
                break;
            case R.id.look_btn:
                if(workers==null){
                    show("数据还未初始化完，初始化完再试");
                }
                else
                    LookServersActivity.launch(this,workers);
                break;
            case R.id.collect_btn:
                if(workers==null){
                    show("数据还未初始化完，初始化完再试");
                }
                else
                    MyCollectionActivity.launch(this,workers);
                break;
        }
    }

    @Override
    public void onBackPressed() {
        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }

/*
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.navigation, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
*/

    @SuppressWarnings("StatementWithEmptyBody")
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        /*if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        }*/
        // Handle navigation view item clicks here
        int id = item.getItemId();
        Intent intent = null;
        if (id == R.id.nav_order) {
            // Handle the camera action
            // word.setText("1");
            //  Toast.makeText(this,"1",Toast.LENGTH_LONG).show();
            if (!mId.equals(""))
            {
                intent = new Intent(this, OrderActivity.class);
                intent.putExtra("flag", 1);
                startActivity(intent);
            }
            else
                show("请登录后操作");


 /*       } else if (id == R.id.nav_history) {
            intent=new Intent(this,HistoryActivity.class);
            startActivity(intent);
            //word.setText("2");
            // Toast.makeText(this,"2",Toast.LENGTH_LONG);
        } else if (id == R.id.nav_share) {
            intent=new Intent(this,ShareActivity.class);
            startActivity(intent);
           // word.setText("3");
            // Toast.makeText(this,"3",Toast.LENGTH_LONG);*/
        } else if (id == R.id.nav_manage) {
            // intent=new Intent(this,SettingActivity.class);
            //startActivity(intent);
            if (!mId.equals(""))
                SettingActivity.launch(this);//,REQUEST_SETTING);
            else
                show("请登录后操作");
            // word.setText("4");
            // Toast.makeText(this,"4",Toast.LENGTH_LONG);
        } else if (id == R.id.nav_about) {
            intent = new Intent(this, AboutActivity.class);
            startActivity(intent);
            // word.setText("5");
            // Toast.makeText(this, "5", Toast.LENGTH_LONG);
        } /*else if (id == R.id.nav_send) {
            word.setText("6");
            //Toast.makeText(this,"6",Toast.LENGTH_LONG);
        }*/
        //if(intent!=null)
//             startActivity(intent);
//        DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
//        drawer.closeDrawer(GravityCompat.START);
        return false;
    }


    public void finish() {
        super.finish();
        overridePendingTransition(0, R.anim.default_amin_out);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            if (requestCode == REQUEST_UPDATE) {
                // new DialogUtils(NavigationActivity.this, "center", true, 0).setMessage("fanhui").setButtons(null, "确定", null).create().show();
                String name = MyApplication.local.getString(mId + LocalPreferencesHelper.USER_NAME);
                String head = MyApplication.local.getString(mId + LocalPreferencesHelper.USER_HEAD_URL);
                //data.getStringExtra("name");
                if (!name.equals(""))
                    mName.setText(name);
                if (!head.equals("")) {
                    String userHead = HttpProtocolFactory.HOST_URL_USER + head;
                    // new DialogUtils(NavigationActivity.this, "center", true, 0).setMessage(userHead).setButtons(null, "确定", null).create().show();
                    Glide.with(NavigationActivity.this)
                            .load(userHead)
                                    // .crossFade()
                                    //  .placeholder(R.drawable.head_small)
                            .into(mCircleImage);

                    Glide.with(NavigationActivity.this)
                            .load(userHead)
                                    // .crossFade()
                                    //  .placeholder(R.drawable.head_small)
                            .into(img_head_view);
                    // Glide.clear(mCircleImage);
                }
/*                String fileString=data.getStringExtra("head");
                if(fileString!=null) {
                    Uri uri=Uri.fromFile(new File(fileString));
                    Bitmap bitmap=CropImageUtils.decodeUriAsBitmap(this,uri);
                    mCircleImage.setImageBitmap(bitmap);
                    img_head_view.setImageBitmap(bitmap);
                }*/
            }
         /*   if (requestCode == REQUEST_SETTING) {

                Boolean isLogouted=data.getBooleanExtra("is_logouted",false);

            }*/
        }
    }

 /*   private Bitmap decodeUriAsBitmap(Uri uri){
        Bitmap bitmap = null;
        try {
            bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
            return null;
        }
        return bitmap;
    }*/
}
